package com.bdan.t382.entity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class Printer {
    private InkTank inkTank;
    private Paper paper;

    public Printer() {

    }

    // 添加带有InkTank参数的构造方法
    public Printer(InkTank inkTank) {
        this.inkTank = inkTank;
    }


    @Autowired
    public Printer(@Qualifier("colorInkTank") InkTank inkTank, @Qualifier("a4Paper") Paper paper) {
        this.inkTank = inkTank;
        this.paper = paper;
    }

    public InkTank getInkTank() {
        return inkTank;
    }

    public void setInkTank(InkTank inkTank) {
        this.inkTank = inkTank;
    }

    public Paper getPaper() {
        return paper;
    }

    public void setPaper(Paper paper) {
        this.paper = paper;
    }

    public void print(String text) {
        System.out.println("使用 " + inkTank.getColor() + " 墨盒在 " + (paper!= null? paper.getSize() : "未指定纸张") + " 纸张上打印: " + text);
    }
}
